<template>
  <a-date-picker v-model:value="value" @change="change" :format="format" v-bind="$attrs" />
</template>

<script>
import { ref } from '@vue/reactivity'
import moment from 'moment';
import {formDate} from "@utils/formDate.js"
export default {
    props:{
        currentVal:{
            type:String,
            default:formDate(new Date(),"-")
        },
        format:{
            type:String,
            required:true
        }
    },
    setup(props,{emit}){
        // 响应式数据
        let value = ref(moment(props.currentVal,props.format))

        // 双向绑定数据
        const change = (moment,e)=>{
            emit("update:currentVal",e)
        }

        return{
            value,
            moment,
            change,
        }
    }
}
</script>

<style>

</style>